
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.Except;
import cn.edu.scau.cmi.hombio.domain.ExceptionType;
import cn.edu.scau.cmi.hombio.domain.ExceptionTypeEmployee;
import cn.edu.scau.cmi.hombio.domain.InspectionException;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class ExceptionTypeServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected ExceptionTypeService service;

	/**
	 * Instantiates a new ExceptionTypeServiceTest.
	 *
	 */
	public ExceptionTypeServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Save an existing ExceptionType entity
	* 
	 */
	@Test
	public void saveExceptionType() {
		// TODO: JUnit - Populate test inputs for operation: saveExceptionType 
		ExceptionType exceptiontype = new cn.edu.scau.cmi.hombio.domain.ExceptionType();
		service.saveExceptionType(exceptiontype);
	}

	/**
	 * Operation Unit Test
	* Delete an existing Except entity
	* 
	 */
	@Test
	public void deleteExceptionTypeExcepts() {
		// TODO: JUnit - Populate test inputs for operation: deleteExceptionTypeExcepts 
		Integer exceptiontype_id = 0;
		Integer related_excepts_id = 0;
		ExceptionType response = null;
		response = service.deleteExceptionTypeExcepts(exceptiontype_id, related_excepts_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteExceptionTypeExcepts
	}

	/**
	 * Operation Unit Test
	* Save an existing InspectionException entity
	* 
	 */
	@Test
	public void saveExceptionTypeInspectionExceptions() {
		// TODO: JUnit - Populate test inputs for operation: saveExceptionTypeInspectionExceptions 
		Integer id = 0;
		InspectionException related_inspectionexceptions = new cn.edu.scau.cmi.hombio.domain.InspectionException();
		ExceptionType response = null;
		response = service.saveExceptionTypeInspectionExceptions(id, related_inspectionexceptions);
		// TODO: JUnit - Add assertions to test outputs of operation: saveExceptionTypeInspectionExceptions
	}

	/**
	 * Operation Unit Test
	* Save an existing Except entity
	* 
	 */
	@Test
	public void saveExceptionTypeExcepts() {
		// TODO: JUnit - Populate test inputs for operation: saveExceptionTypeExcepts 
		Integer id_1 = 0;
		Except related_excepts = new cn.edu.scau.cmi.hombio.domain.Except();
		ExceptionType response = null;
		response = service.saveExceptionTypeExcepts(id_1, related_excepts);
		// TODO: JUnit - Add assertions to test outputs of operation: saveExceptionTypeExcepts
	}

	/**
	 * Operation Unit Test
	* Delete an existing InspectionException entity
	* 
	 */
	@Test
	public void deleteExceptionTypeInspectionExceptions() {
		// TODO: JUnit - Populate test inputs for operation: deleteExceptionTypeInspectionExceptions 
		Integer exceptiontype_id_1 = 0;
		Integer related_inspectionexceptions_id = 0;
		ExceptionType response = null;
		response = service.deleteExceptionTypeInspectionExceptions(exceptiontype_id_1, related_inspectionexceptions_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteExceptionTypeInspectionExceptions
	}

	/**
	 * Operation Unit Test
	* Return all ExceptionType entity
	* 
	 */
	@Test
	public void findAllExceptionTypes() {
		// TODO: JUnit - Populate test inputs for operation: findAllExceptionTypes 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<ExceptionType> response = null;
		response = service.findAllExceptionTypes(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllExceptionTypes
	}

	/**
	 * Operation Unit Test
	* Load an existing ExceptionType entity
	* 
	 */
	@Test
	public void loadExceptionTypes() {
		Set<ExceptionType> response = null;
		response = service.loadExceptionTypes();
		// TODO: JUnit - Add assertions to test outputs of operation: loadExceptionTypes
	}

	/**
	 * Operation Unit Test
	* Return a count of all ExceptionType entity
	* 
	 */
	@Test
	public void countExceptionTypes() {
		Integer response = null;
		response = service.countExceptionTypes();
		// TODO: JUnit - Add assertions to test outputs of operation: countExceptionTypes
	}

	/**
	 * Operation Unit Test
	* Delete an existing ExceptionType entity
	* 
	 */
	@Test
	public void deleteExceptionType() {
		// TODO: JUnit - Populate test inputs for operation: deleteExceptionType 
		ExceptionType exceptiontype_1 = new cn.edu.scau.cmi.hombio.domain.ExceptionType();
		service.deleteExceptionType(exceptiontype_1);
	}

	/**
	 * Operation Unit Test
	* Delete an existing ExceptionTypeEmployee entity
	* 
	 */
	@Test
	public void deleteExceptionTypeExceptionTypeEmployees() {
		// TODO: JUnit - Populate test inputs for operation: deleteExceptionTypeExceptionTypeEmployees 
		Integer exceptiontype_id_2 = 0;
		Integer related_exceptiontypeemployees_id = 0;
		ExceptionType response = null;
		response = service.deleteExceptionTypeExceptionTypeEmployees(exceptiontype_id_2, related_exceptiontypeemployees_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteExceptionTypeExceptionTypeEmployees
	}

	/**
	 * Operation Unit Test
	* Save an existing ExceptionTypeEmployee entity
	* 
	 */
	@Test
	public void saveExceptionTypeExceptionTypeEmployees() {
		// TODO: JUnit - Populate test inputs for operation: saveExceptionTypeExceptionTypeEmployees 
		Integer id_2 = 0;
		ExceptionTypeEmployee related_exceptiontypeemployees = new cn.edu.scau.cmi.hombio.domain.ExceptionTypeEmployee();
		ExceptionType response = null;
		response = service.saveExceptionTypeExceptionTypeEmployees(id_2, related_exceptiontypeemployees);
		// TODO: JUnit - Add assertions to test outputs of operation: saveExceptionTypeExceptionTypeEmployees
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findExceptionTypeByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findExceptionTypeByPrimaryKey 
		Integer id_3 = 0;
		ExceptionType response = null;
		response = service.findExceptionTypeByPrimaryKey(id_3);
		// TODO: JUnit - Add assertions to test outputs of operation: findExceptionTypeByPrimaryKey
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
